package com.jxwifi.cloud.quickclean.complaint;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.basicactivity.BasicActivity;
import com.idroid.utils.NoDoubleClickListener;
import com.jxwifi.cloud.quickclean.adapter.ConplaintAdapter;
import com.jxwifi.cloud.quickclean.app.AccountMgr;
import com.jxwifi.cloud.quickclean.app.ClientBasicActivity;
import com.jxwifi.cloud.quickclean.app.PasswordLogin;
import com.jxwifi.cloud.quickclean.bean.AddPreOrderResVoBean;
import com.jxwifi.cloud.quickclean.bean.OrderInfoBean;
import com.jxwifi.cloud.quickclean.utils.TitleClient;
import com.jxwifi.cloud.quickclean.R;
import com.jxwifi.cloud.quickclean.utils.ToastUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 投诉页面
 * Created by Administrator on 2019/6/11.
 */

public class ComplaintActivity extends ClientBasicActivity implements ComplaintView{

    @Bind(R.id.tv_complaint_order_content)
    TextView mTvComplaintOrderContent;//订单编码
    @Bind(R.id.tv_complaint_service_type)
    TextView mTvComplaintServiceType;//服务类型
    @Bind(R.id.tv_complaint_service_time)
    TextView mTvComplaintServiceTime;//服务时间
    @Bind(R.id.tv_complaint_service_address)
    TextView mTvComplaintServiceAddress;//服务地址
    @Bind(R.id.tv_complaint_phone)
    TextView mTvComplaintPhone;//电话
    @Bind(R.id.tv_complaint_measure)
    TextView mTvComplaintMeasure;//保洁面积
    @Bind(R.id.rv_complaint_list)
    RecyclerView mRvComplaintList;

    private OrderInfoBean mOrderinfo;

    private ComplaintPresenter mPresenter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_complaint);
        ButterKnife.bind(this);
        openEventBus();
        mOrderinfo=(OrderInfoBean) getIntent().getExtras().getSerializable("orderinfo");
        mPresenter=new ComplaintPresenter(mBaseContext,this);
        initHead();
        mPresenter.initView();
    }

    private void initHead() {
        TitleClient holder = new TitleClient(ButterKnife.findById(this, R.id.lin_client_title));
        holder.defineTitle("订单投诉");
        holder.defineLeft(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                onBackPressed();
            }
        });
    }

    @Override
    public TextView getMeasure() {
        return mTvComplaintMeasure;
    }

    @Override
    public TextView getComplaintPhone() {
        return mTvComplaintPhone;
    }

    @Override
    public TextView getServiceAddress() {
        return mTvComplaintServiceAddress;
    }

    @Override
    public TextView getServiceTime() {
        return mTvComplaintServiceTime;
    }

    @Override
    public TextView getServiceType() {
        return mTvComplaintServiceType;
    }

    @Override
    public TextView getOrderContent() {
        return mTvComplaintOrderContent;
    }

    @Override
    public OrderInfoBean getOrderInfo() {
        return mOrderinfo;
    }

    @Override
    public RecyclerView getComplaintList() {
        return mRvComplaintList;
    }

    @Override
    public void onFailure(int errorCode, String msg) {
        Toast toast = Toast.makeText(mBaseContext, msg, Toast.LENGTH_SHORT);
        ToastUtils.showMyToast(toast, 3000);
    }

    @Override
    public void onfinshs() {
        finish();
    }

    @Override
    public void onCustomer() {
        PasswordLogin.passwordlogin(mBaseContext, TAG, AccountMgr.gettell(mBaseContext), AccountMgr.getpassword(mBaseContext));
        if (PasswordLogin.mIsLogin) {
            mPresenter.Customer();
        }
    }
}
